<template>
    <div>
        <button @click="test">test</button>
        图像
        <svg-icon icon-class="example" style="width: 56px;height: 56px;color: #409EFF"></svg-icon>
        <p :v-html=html v-show="flag">1232</p>
    </div>
<!--    <div>-->
<!--        <div id="qrcode" ref="qrcode"></div>-->
<!--    </div>-->
</template>

<script>
    import QRCode from 'qrcodejs2'
    import axios from 'axios';
    import {homeContent} from "../api/home";
    import {areaList as globalAreaList} from '@vant/area-data';
    import request from "../utils/request";
    import {testHttp} from '../api/test'
    export default {
        name: "Test",
        data(){
            return {
                areaList: globalAreaList,
                html: null,
                flag: false
            }
        },
        methods: {
            qrcodeScan () {//生成二维码
                let qrcode = new QRCode('qrcode', {
                    width: 200,  // 二维码宽度
                    height: 200, // 二维码高度
                    text: 'https://qr.alipay.com/bax08466rpb2pwjwvlnt009b'
                })
            },
            test(){
                axios.post('http://localhost:8700/alipay/pay?money=0.1&subject=AvaMall收款中心&tradeNo=12345678').then(res => {
                // axios.get('http://localhost:8700/alipay/test').then(res => {
                    console.log(res.data.msg)
                    const divForm = document.getElementsByTagName('divform')
                    if (divForm.length) {
                        document.body.removeChild(divForm[0])
                    }
                    const div = document.createElement('divform')

                    div.innerHTML = res.data.msg // data就是接口返回的form 表单字符串
                    document.body.appendChild(div)
                    document.forms[0].setAttribute('target', '_blank') // 新开窗口跳转
                    document.forms[0].submit()
                })
            }
        },
        created() {

        },
        mounted() {
            this.qrcodeScan();
        }
    }
</script>

<style scoped>

</style>
